<?php

/**
 * 餐厅编辑post
 * 
 * @copyright xinwei
 * @since 2012-04-17
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] . "/include/foodv2/pinyin/zh2py.php");

$g_cgival = array();
$g_pro = array();
$g_show = array();

function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
	
	//check refer  -  add by xinwei
	if(! security_check::check_refer())
	{
		throw new Exception("来路不明");
	}
	
	//是否添加分店操作
	cgi::both($g_cgival["Chain"], "Chain", 0);
	$g_cgival["Chain"] = intval($g_cgival["Chain"]);
	
	//餐厅总店ID
	cgi::both($g_cgival["RstrtPID"], "RstrtPID", 0);
	$g_cgival["RstrtPID"] = intval($g_cgival["RstrtPID"]);
	
	//连锁店名称
	cgi::post($g_cgival["RstrtChainName"], "RstrtChainName", "");
	$g_cgival["RstrtChainName"] = string::un_script_code($g_cgival["RstrtChainName"]);
	$g_cgival["RstrtChainName"] = string::un_html($g_cgival["RstrtChainName"]);
	
	
	//餐厅ID
	cgi::both($g_cgival["rstrt_id"], "rstrt_id", 0);
	$g_cgival["rstrt_id"] = intval($g_cgival["rstrt_id"]);
	
	//餐厅名称
	cgi::post($g_cgival["RstrtName"], "RstrtName", "");
	$g_cgival["RstrtName"] = string::un_script_code($g_cgival["RstrtName"]);
	$g_cgival["RstrtName"] = string::un_html($g_cgival["RstrtName"]);
	if(empty($g_cgival["RstrtName"]) && $_POST["RstrtPic"])
	{
		throw new Exception("请填写餐厅名称。");
	}
	
	//餐厅图片
	cgi::post($g_cgival["RstrtPic"], "RstrtPic", "");
	$g_cgival["RstrtPic"] = string::un_script_code($g_cgival["RstrtPic"]);
	$g_cgival["RstrtPic"] = string::un_html($g_cgival["RstrtPic"]);
	
	
	//微博UID
	cgi::post($g_cgival["RstrtWeiboID"], "RstrtWeiboID", "");
	$g_cgival["RstrtWeiboID"] = string::un_script_code($g_cgival["RstrtWeiboID"]);
	$g_cgival["RstrtWeiboID"] = string::un_html($g_cgival["RstrtWeiboID"]);
	
	//别名
	cgi::post($g_cgival["cname"], "cname", "");
	$g_cgival["cname"] = string::un_script_code($g_cgival["cname"]);
	$g_cgival["cname"] = string::un_html($g_cgival["cname"]);
	
	//菜系
	cgi::post($g_cgival["RstrtFlavorByAddr"], "RstrtFlavorByAddr", '');
	if(!empty($g_cgival["RstrtFlavorByAddr"]) && count($g_cgival["RstrtFlavorByAddr"])>0)
	{
		foreach($g_cgival["RstrtFlavorByAddr"] as $i => $val)
		{
			$val = string::un_script_code($val);
			$g_cgival["RstrtFlavorByAddr"][$i] = string::un_html($val);
		}
	}
	
	//风味
	cgi::post($g_cgival["RstrtFlavorByType"], "RstrtFlavorByType", '');
	if(!empty($g_cgival["RstrtFlavorByType"]) && count($g_cgival["RstrtFlavorByType"])>0)
	{
		foreach($g_cgival["RstrtFlavorByType"] as $i => $val)
		{
			$val = string::un_script_code($val);
			$g_cgival["RstrtFlavorByType"][$i] = string::un_html($val);
		}
	}
	
	//餐厅简介
	cgi::post($g_cgival["RstrtInfo"], "RstrtInfo", '');
	$g_cgival["RstrtInfo"] = string::un_script_code($g_cgival["RstrtInfo"]);
	$g_cgival["RstrtInfo"] = string::un_html($g_cgival["RstrtInfo"]);
	
	//推荐菜品
	cgi::post($g_cgival["RstrtFood"], "RstrtFood", '');
	$g_cgival["RstrtFood"] = string::un_script_code($g_cgival["RstrtFood"]);
	$g_cgival["RstrtFood"] = string::un_html($g_cgival["RstrtFood"]);
	
	//特色服务
	cgi::post($g_cgival["rstrt_service"], "rstrt_service", '');
	if(!empty($g_cgival["rstrt_service"]) && count($g_cgival["rstrt_service"])>0)
	{
		foreach($g_cgival["rstrt_service"] as $i => $val)
		{
			$val = string::un_script_code($val);
			$g_cgival["rstrt_service"][$i] = string::un_html($val);
		}
	}
	
	//餐厅环境
	cgi::post($g_cgival["rstrt_env"], "rstrt_env", '');
	if(!empty($g_cgival["rstrt_env"]) && count($g_cgival["rstrt_env"])>0)
	{
		foreach($g_cgival["rstrt_env"] as $i => $val)
		{
			$val = string::un_script_code($val);
			$g_cgival["rstrt_env"][$i] = string::un_html($val);
		}
	}
	
	//人均消费
	cgi::both($g_cgival["RstrtPayAverage"], "RstrtPayAverage", 0);
	$g_cgival["RstrtPayAverage"] = intval($g_cgival["RstrtPayAverage"]);
	if(empty($g_cgival["RstrtPayAverage"])&&!$_FILES)
	{
		throw new Exception("请填写人均消费。");
	}
	
	//开业时间
	cgi::post($g_cgival["RstrtOpenTime"], "RstrtOpenTime", '');
	$g_cgival["RstrtOpenTime"] = string::un_script_code($g_cgival["RstrtOpenTime"]);
	$g_cgival["RstrtOpenTime"] = string::un_html($g_cgival["RstrtOpenTime"]);
	
	//结业时间
	cgi::post($g_cgival["RstrtCloseTime"], "RstrtCloseTime", '');
	$g_cgival["RstrtCloseTime"] = string::un_script_code($g_cgival["RstrtCloseTime"]);
	$g_cgival["RstrtCloseTime"] = string::un_html($g_cgival["RstrtCloseTime"]);
	
	//联系电话
	cgi::post($g_cgival["RstrtTel"], "RstrtTel", '');
	$g_cgival["RstrtTel"] = string::un_script_code($g_cgival["RstrtTel"]);
	$g_cgival["RstrtTel"] = string::un_html($g_cgival["RstrtTel"]);
	
	//餐厅地址 - 市
	cgi::post($g_cgival["RstrtCity"], "RstrtCity", '');
	$g_cgival["RstrtCity"] = string::un_script_code($g_cgival["RstrtCity"]);
	$g_cgival["RstrtCity"] = string::un_html($g_cgival["RstrtCity"]);
	
	//餐厅地址 - 区
	cgi::post($g_cgival["RstrtRegion"], "RstrtRegion", '');
	$g_cgival["RstrtRegion"] = string::un_script_code($g_cgival["RstrtRegion"]);
	$g_cgival["RstrtRegion"] = string::un_html($g_cgival["RstrtRegion"]);
	
	//餐厅地址 - 商圈
	cgi::post($g_cgival["RstrtArea"], "RstrtArea", '');
	$g_cgival["RstrtArea"] = string::un_script_code($g_cgival["RstrtArea"]);
	$g_cgival["RstrtArea"] = string::un_html($g_cgival["RstrtArea"]);
	
	//餐厅地址 - 街道
	cgi::post($g_cgival["RstrtRoad"], "RstrtRoad", '');
	$g_cgival["RstrtRoad"] = string::un_script_code($g_cgival["RstrtRoad"]);
	$g_cgival["RstrtRoad"] = string::un_html($g_cgival["RstrtRoad"]);
	
	//餐厅地址
	cgi::post($g_cgival["RstrtAddr"], "RstrtAddr", '');
	$g_cgival["RstrtAddr"] = string::un_script_code($g_cgival["RstrtAddr"]);
	$g_cgival["RstrtAddr"] = string::un_html($g_cgival["RstrtAddr"]);
	if(empty($g_cgival["RstrtAddr"])&&!$_FILES)
	{
		throw new Exception("请填写餐厅地址。");
	}
	
	//地图 - 经度
	cgi::post($g_cgival["lang"], "lang", '');
	$g_cgival["lang"] = string::un_script_code($g_cgival["lang"]);
	$g_cgival["lang"] = string::un_html($g_cgival["lang"]);
	
	//地图 - 纬度
	cgi::post($g_cgival["lat"], "lat", '');
	$g_cgival["lat"] = string::un_script_code($g_cgival["lat"]);
	$g_cgival["lat"] = string::un_html($g_cgival["lat"]);
	
	//交通路线
	cgi::post($g_cgival["RstrtTraffic"], "RstrtTraffic", '');
	$g_cgival["RstrtTraffic"] = string::un_script_code($g_cgival["RstrtTraffic"]);
	$g_cgival["RstrtTraffic"] = string::un_html($g_cgival["RstrtTraffic"]);


}

function get_data()
{
	global $g_cgival, $g_pro, $g_show,$config;
	
	$db = new db_web_rstrt();
	$db_cname = new db_web_rstrt_cname();
	$db_tag = new db_food_tag();
	$db_rstrt_tag = new db_web_rstrt_tag();
	$db_area = new db_eat_area();
	$admin_log = new admin_log();
	
	// 拿到当前站点的site_id
	$site_id = admin::admin_get_user_site_id();
	$admin_name = admin::admin_get_login_user_name();
	$admin_id = admin::admin_get_login_uid();
	
	//推荐菜品处理
	$RstrtFoodArr = explode(",",$g_cgival["RstrtFood"]);
	
	if ($_FILES['file1'])
	{

		try
		{
			if($_FILES['file1']['size']>3145728)
			{
				throw new Exception("请上传3M以内的图片。");
			}
			
			/* 上传图片 */
			$upload = new s3_upload();
			$filename = "/cove_template/".time();
			$g_show['data'] = $upload->show($_FILES['file1'])->zomm(250,180)->save($filename);
			$g_show['data'] = $g_show['data']['src'];
		}
		catch (Exception $e)
		{
			throw new Exception($e->getMessage(), 1);
			
		}
		return;
	}
	
	if($g_cgival["rstrt_id"])
	{	
		/* 更新 */
		
		//获取餐厅信息
		$info = $db->admin_get_rstrt_by_ids(array($g_cgival["rstrt_id"]));
		$data['rstrt_info'] = $info[0];
		
		//检查权限是否正常 排除总站帐号
		if($site_id != 900 && $data['rstrt_info']["site_id"] != $site_id)
		{
			throw new Exception("您没有权限操作该条信息。");
		}
		
		/* 记录 
		RstrtNamePinyinAlias   拼音转换
		别名处理 yes
		菜系处理 yes
		风味处理 yes
		服务处理 yes
		环境处理 yes
		*/
		
		//拼音处理
		$RstrtNamePinyinAlias = getPinyin($g_cgival["RstrtName"]);
		
		
		//别名处理
		$db_cname->admin_delete_cname_by_res_id($g_cgival["rstrt_id"]);
		if($g_cgival["cname"])
		{
			//edit by xinwei 2012-06-14  修改分割逻辑，空格改逗号
			$cnameArr = explode(",",$g_cgival["cname"]);
			if(is_array($cnameArr) && count($cnameArr)>0)
			{
				foreach($cnameArr as $i => $val)
				{
//					if()
//					{
//						
//					}
					if($val)
					{
						$db_cname->admin_insert_rstrt_cname($g_cgival["rstrt_id"],$val,$admin_id,$admin_name);
					}
					if($i >= 4)break;
				}
			}
		}
		
		/* tag处理 - 菜系/风味/服务/环境 */
		$styles = array();
		$flavors = array();

		//tag库 菜系数据
		$styleArr = $db_tag->admin_shangjia_search($site_id, '菜系', '', 1, -1, 1, 10000);
		foreach($styleArr as $i => $val)
		{
			$styles[] = $val["tag_name"];			
		}

		//tag库 商圈数据
		$areaArr = $db_tag->admin_shangjia_search($site_id, '商圈', '', 1, -1, 1, 10000);
		foreach($areaArr as $i => $val)
		{
			$areas[] = $val["tag_name"];			
		}

		//config 服务数据
		$config['rstrt_service'];
		
		//config 环境数据
		$config['rstrt_env'];
		
		//清除以上4类tag
		$tag = $db_rstrt_tag->admin_get_tag_list($g_cgival["rstrt_id"],'','',1,1000); 
		if($tag)
		{
			foreach($tag as $i => $val)
			{
				if(
				in_array($val["tag"],$styles) 
				|| in_array($val["tag"],$areas)
				|| in_array($val["tag"],$config['rstrt_service'])
				|| in_array($val["tag"],$config['rstrt_env'])
				|| in_array($val["tag"],$RstrtFoodArr)
				)
				{
					$delTagId[] = $val["id"];
				}
			}
			$db_rstrt_tag->admin_delete_tag_by_ids($delTagId);
		}
		
		//菜系tag插入
		if(is_array($g_cgival["RstrtFlavorByAddr"]) && count($g_cgival["RstrtFlavorByAddr"])>0)
		{
			foreach($g_cgival["RstrtFlavorByAddr"] as $i => $val)
			{
				if($val)
				{
					$db_rstrt_tag->admin_insert_rstrt_tag('123456',$g_cgival["rstrt_id"],$val,1,1,$admin_id,$admin_name);
				}
			}
		}

		//服务tag插入
		if(is_array($g_cgival["rstrt_service"]) && count($g_cgival["rstrt_service"])>0)
		{
			foreach($g_cgival["rstrt_service"] as $i => $val)
			{
				if($val)
				{
					$db_rstrt_tag->admin_insert_rstrt_tag('123456',$g_cgival["rstrt_id"],$val,1,1,$admin_id,$admin_name);
				}
			}
		}

		//环境tag插入
		if(is_array($g_cgival["rstrt_env"]) && count($g_cgival["rstrt_env"])>0)
		{
			foreach($g_cgival["rstrt_env"] as $i => $val)
			{
				if($val)
				{
					$db_rstrt_tag->admin_insert_rstrt_tag('123456',$g_cgival["rstrt_id"],$val,1,1,$admin_id,$admin_name);
				}
			}
		}
		
		//推荐菜品tag插入
		if(is_array($RstrtFoodArr) && count($RstrtFoodArr)>0)
		{
			foreach($RstrtFoodArr as $i => $val)
			{
				if($val)
				{
					$db_rstrt_tag->admin_insert_rstrt_tag('123456',$g_cgival["rstrt_id"],$val,1,1,$admin_id,$admin_name);
				}
			}
		}
		
		//商圈tag插入
		if(!empty($g_cgival["RstrtArea"]) && $g_cgival["RstrtArea"] != -1)
		{
			$db_rstrt_tag->admin_insert_rstrt_tag('123456',$g_cgival["rstrt_id"],$g_cgival["RstrtArea"],1,1,$admin_id,$admin_name);
		}
		
		
		/* tag处理 end */

		//地图坐标处理
		$RstrtOnMapNum = "lat:".sprintf("%.5f",$g_cgival["lat"]).",lng:".sprintf("%.5f",$g_cgival["lang"]);
		
		//餐厅表信息更新
		$updateArr = array(
			"RstrtID" => $g_cgival["rstrt_id"],
			"site_id" => $site_id,
			"RstrtUid" => $g_cgival["RstrtUid"],
			"RstrtUserName" => '',
			"RstrtWeiboAccount" => '',
			"RstrtName" => $g_cgival["RstrtName"],
			"RstrtNamePinyinAlias" => $RstrtNamePinyinAlias,
			"RstrtPark" => '',
			"RstrtFavour" => '',
			"RstrtUseCard" => '',
			"RstrtFlavorByAddr" => '',
			"RstrtFlavorByType" => '',
			"RstrtKeyword" => '',
			"RstrtTel" => $g_cgival["RstrtTel"],
			"RstrtArea" => $g_cgival["RstrtArea"],
			"RstrtPayAverage" => $g_cgival["RstrtPayAverage"],
			"RstrtAddr" => $g_cgival["RstrtAddr"],
			"RstrtOpenTime" => $g_cgival["RstrtOpenTime"],
			"RstrtCloseTime" => $g_cgival["RstrtCloseTime"],
			"RstrtRegion" => $g_cgival["RstrtRegion"],
			"RstrtRoad" => $g_cgival["RstrtRoad"],
			"RstrtRoadNum" => '',
			"RstrtBuilding" => '',
			"RstrtBuildingFloor" => '',
			"RstrtBuildingNum" => '',
			"RstrtCross" => '',
			"RstrtChain" => "{$g_cgival["RstrtChain"]}",
			"RstrtChainName" => "{$g_cgival["RstrtChainName"]}",
			"RstrtTraffic" => $g_cgival["RstrtTraffic"],
			"RstrtInfo" => $g_cgival["RstrtInfo"],
			"RstrtCity" => $g_cgival["RstrtCity"],
			"RstrtWeiboID" => $g_cgival["RstrtWeiboID"],
			"RstrtWeiboAccount" => '',
			"RstrtSubmitUsr" => $admin_name,
			"RstrtFood" => $g_cgival["RstrtFood"],
			"RstrtTjReason" => '',
			"RstrtPic" => $g_cgival["RstrtPic"],
			"RstrtSubmitUID" => $admin_id,
			"RstrtDishFavor" => '',
			"RstrtSpclServ" => '',
			"RstrtEnv" => '',
			"RstrtPics" => '',
			"RstrtOnMapNum" => $RstrtOnMapNum,
			"RstrtMIDNum" => '',
			"RstrtCommend" => '',
			"RstrtPID" => 0,
			"RstrtFrom" => '',
			"RstrtGrand"=> ''
		);
		
		if($g_cgival["Chain"])
		{
			$updateArr["RstrtChain"] = "1";
		}
		else 
		{
			$updateArr["RstrtChain"] = "0";
			unset($updateArr["RstrtPID"]);
			unset($updateArr["RstrtChain"]);
			unset($updateArr["RstrtChainName"]);			
		}
			
		$update = $db->update_rstrt(
			$updateArr
		);
		$g_show["RstrtPID"] = $g_cgival["rstrt_id"];
		
		$admin_log->admin_insert_log_info($admin_id, $site_id, 18, "编辑 餐厅id={$g_cgival["rstrt_id"]}");
	}
	else
	{
		/* 新增 */

		//拼音处理
		$RstrtNamePinyinAlias = getPinyin($g_cgival["RstrtName"]);

		//地图坐标处理
		$RstrtOnMapNum = "lat:".sprintf("%.5f",$g_cgival["lat"]).",lng:".sprintf("%.5f",$g_cgival["lang"]);
		
		//餐厅表信息新增		
		$insert = $db->insert_rstrt(
			array(
			"site_id" => $site_id,
			"RstrtUid" => $g_cgival["RstrtUid"],
			"RstrtUserName" => '',
			"RstrtWeiboAccount" => '',
			"RstrtName" => $g_cgival["RstrtName"],
			"RstrtNamePinyinAlias" => $RstrtNamePinyinAlias,
			"RstrtPark" => '',
			"RstrtFavour" => '',
			"RstrtUseCard" => '',
			"RstrtFlavorByAddr" => '',
			"RstrtFlavorByType" => '',
			"RstrtKeyword" => '',
			"RstrtTel" => $g_cgival["RstrtTel"],
			"RstrtArea" => $g_cgival["RstrtArea"],
			"RstrtPayAverage" => $g_cgival["RstrtPayAverage"],
			"RstrtAddr" => $g_cgival["RstrtAddr"],
			"RstrtOpenTime" => $g_cgival["RstrtOpenTime"],
			"RstrtCloseTime" => $g_cgival["RstrtCloseTime"],
			"RstrtRegion" => $g_cgival["RstrtRegion"],
			"RstrtRoad" => $g_cgival["RstrtRoad"],
			"RstrtRoadNum" => '',
			"RstrtBuilding" => '',
			"RstrtBuildingFloor" => '',
			"RstrtBuildingNum" => '',
			"RstrtCross" => '',
			"RstrtTraffic" => $g_cgival["RstrtTraffic"],
			"RstrtInfo" => $g_cgival["RstrtInfo"],
			"RstrtCity" => $g_cgival["RstrtCity"],
			"RstrtWeiboID" => $g_cgival["RstrtWeiboID"],
			"RstrtWeiboAccount" => '',
			"RstrtSubmitUsr" => '',
			"RstrtFood" => $g_cgival["RstrtFood"],
			"RstrtTjReason" => '',
			//"RstrtShow" => '', // 不修改审核状态
			"RstrtPic" => $g_cgival["RstrtPic"],
			"RstrtSubmitUID" => '',
			"RstrtDishFavor" => '',
			"RstrtSpclServ" => '',
			"RstrtEnv" => '',
			"RstrtPics" => '',
			"RstrtOnMapNum" => $RstrtOnMapNum,
			"RstrtMIDNum" => '',
			"RstrtCommend" => '',
			"RstrtFrom" => '',
			"RstrtGrand"=> ''
			)
		);
		
		if($insert)
		{
			//分店处理
			if($g_cgival["Chain"])
			{
				$updateArr = array(
					"RstrtID" => $insert,
					"RstrtChain" => "{$g_cgival["RstrtChain"]}",
					"RstrtChainName" => "{$g_cgival["RstrtChainName"]}",
					"RstrtPID" => $g_cgival["RstrtPID"]==$insert?0:$insert
				);
				$db->update_rstrt($updateArr);
				$g_cgival["RstrtPID"] = $insert;
			}
			//别名处理
			if($g_cgival["cname"])
			{
				$cnameArr = explode(" ",$g_cgival["cname"]);
				if(is_array($cnameArr) && count($cnameArr)>0)
				{
					foreach($cnameArr as $i => $val)
					{
						if($val)
						{
							$db_cname->admin_insert_rstrt_cname($insert,$val,$admin_id,$admin_name);
						}
						if($i >= 4)break;
					}
				}
			}
			
			/* tag处理 - 菜系/风味/服务/环境 */
			
			//菜系tag插入
			if(is_array($g_cgival["RstrtFlavorByAddr"]) && count($g_cgival["RstrtFlavorByAddr"])>0)
			{
				foreach($g_cgival["RstrtFlavorByAddr"] as $i => $val)
				{
					if($val)
					{
						$db_rstrt_tag->admin_insert_rstrt_tag('123456',$insert,$val,1,1,$admin_id,$admin_name);
					}
				}
			}
	
			//服务tag插入
			if(is_array($g_cgival["rstrt_service"]) && count($g_cgival["rstrt_service"])>0)
			{
				foreach($g_cgival["rstrt_service"] as $i => $val)
				{
					if($val)
					{
						$db_rstrt_tag->admin_insert_rstrt_tag('123456',$insert,$val,1,1,$admin_id,$admin_name);
					}
				}
			}
	
			//环境tag插入
			if(is_array($g_cgival["rstrt_env"]) && count($g_cgival["rstrt_env"])>0)
			{
				foreach($g_cgival["rstrt_env"] as $i => $val)
				{
					if($val)
					{
						$db_rstrt_tag->admin_insert_rstrt_tag('123456',$insert,$val,1,1,$admin_id,$admin_name);
					}
				}
			}
			
			//推荐菜品tag插入
			if(is_array($RstrtFoodArr) && count($RstrtFoodArr)>0)
			{
				foreach($RstrtFoodArr as $i => $val)
				{
					if($val)
					{
						$db_rstrt_tag->admin_insert_rstrt_tag('123456',$insert,$val,1,1,$admin_id,$admin_name);
					}
				}
			}
			
			//商圈tag插入
			if(!empty($g_cgival["RstrtArea"]) && $g_cgival["RstrtArea"] != -1)
			{
				$db_rstrt_tag->admin_insert_rstrt_tag('123456',$insert,$g_cgival["RstrtArea"],1,1,$admin_id,$admin_name);
			}

			/* tag处理 end */
			
		}
		
		$admin_log->admin_insert_log_info($admin_id, $site_id, 18, "新增 餐厅");
	}
	
	
	$g_show["data"] = $data;
	

	//当前参数输出到页面	
	$g_show['args'] = $g_cgival;
	$g_show['args']['city'] = $config["site_name"][$site_id]; 
}

$g_show["error"] = 0;
$g_show["errmsg"] = '';
try
{
	admin_check_login();
// 	admin_check_user_priv("foodv2/album_list.php");
	
	check_cgi_pro();
	get_data();
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;


function show_pro()
{
	global $g_cgival, $g_pro, $g_show;
	if(isset($_GET['debug']))
	{
		print_r($g_show);
		exit;
	}
	
	if($g_cgival["Chain"])
	{
		$g_show["url"] = "rstrt_edit.php?RstrtPID={$g_cgival["RstrtPID"]}";
		
	}
	else
	{
		$g_show["url"] = "rstrt_list.php?verify=1";
	}
	echo json_encode($g_show);
}

